<!DOCTYPE html>
<html class="x-admin-sm">
    
    <head>
        <meta charset="UTF-8">
        <title>添加管理员</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="./css/font.css">
        <link rel="stylesheet" href="css/index.css">
       <!-- <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script> -->
       <!-- <script type="text/javascript" src="./js/index.js"></script> -->
       、 <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    </head>  
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                  <div class="layui-form-item">
                      <label for="username" class="layui-form-label">
                          <span class="x-red">*</span>用户ID
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="id"  name="id" required="" 
                          autocomplete="off" class="layui-input ">
                      </div>
                      <div class="layui-form-mid layui-word-aux">
                          <span class="x-red">*</span>用户ID
                      </div>
                  </div>
                  
				  
				 
				  
                

                     
                        
                       
                      </div>
					  
					  <div class="layui-form-item" id="manjian" style="display: none;">
					      <label for="L_pass" class="layui-form-label">
					          <span class="x-red">*</span>门槛金额
					      </label>
					      <div class="layui-input-inline">
					          <input type="text" id="preferentialway" name="preferentialway" required="" 
					          autocomplete="off" class="layui-input">
					      </div>
					      <div class="layui-form-mid layui-word-aux">
					         门槛减金额
					      </div>
					  </div>
                 
                  <div class="layui-form-item">
                      <label for="L_pass" class="layui-form-label">
                          <span class="x-red">*</span>优惠面值
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="parvalue" name="parvalue" required="" 
                          autocomplete="off" class="layui-input">
                      </div>
                      <div class="layui-form-mid layui-word-aux">
                         满减金额
                      </div>
                  </div>
                  <div class="layui-form-item">
                      <label for="L_repass" class="layui-form-label">
                          <span class="x-red">*</span>发放数量
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="totalissued" name="totalissued" required="" 
                          autocomplete="off" class="layui-input">
                      </div>
                  </div>
				     <label class="layui-form-label"><span class="x-red">*</span>门槛</label>
				  
				  <div id="aaa">
				  	<select id="wu"  onclick="zhanshi()">
				  <option value ="0" >无门槛</option>
				   <option value ="1" >有门槛</option>
				  	</select>
				  	
				  </div>
                  <div class="layui-form-item">
                      <label for="L_repass" class="layui-form-label">
                      </label>
                      <button  class="layui-btn" lay-filter="add" lay-submit="" onclick="xinzeng()">
                          增加
                      </button>
                  </div>
              </form>
			  
            </div>
        </div>
		</body>
		<script type="text/javascript">
	
			
			function zhanshi(){
			var op=document.getElementById("wu").value;
				var manjian=document.getElementById("manjian");
				
				if(op==1){
				manjian.style.display="block";
				}else if(op==0){
					manjian.style.display="none";
					
				}
				}
			
			function xinzeng(){
				
				var op=document.getElementById("wu").value;
				var id=document.getElementById("id").value;
				
				var preferentialway=document.getElementById("preferentialway").value;
				var parvalue=document.getElementById("parvalue").value;
				var totalissued=document.getElementById("totalissued").value;
				alert(op+"==op")
				alert(id+"==id")
				alert(preferentialway+"==preferentialway")
				alert(parvalue+"==parvalue")
				alert(totalissued+"==totalissued")
				
				if(op==0){
					preferentialway=0;
				}
				
				$.ajax({
					xhrFields:{withCredentials: true},
				url: "http://localhost:16111/activity/xinzeng",
				mimeType: "post",
				data: {
					users:id,
					preferentialway:preferentialway,
					parvalue:parvalue,
					threshold:op,
					totalissued:totalissued
				},
				dataType: "json",
				
					
				success: function(date){
					console.log(date);
					if(date == 1){
						
					window.location.href="优惠券管理.html";
					}else{
						alert("失败");
					}
					
				},
				});
			}
		
		</script>
     
</html>
